#include <iostream>
#include <cmath>
using namespace std;

int main(){
    int beta = 2;
    int p = 3;
    int L = -1;
    int U = 1;

    cout << "UFL(F): " << pow(beta, L) << endl;
    cout << "OFL(F): " << pow(beta, U) * (beta - pow(beta, 1-p)) << endl;

    cout << "规格化浮点数:\n" << 0 << endl;
    for(int e = L; e <= U; e++){
        double x[4];
        x[0] = 1.00;
        x[1] = 1 + pow(beta, -2);
        x[2] = 1 + pow(beta, -1);
        x[3] = 1 + pow(beta, -1) + pow(beta, -2);
        for(int i = 0; i <= 3; i++){
            cout << x[i] * pow(beta, e) << " ";
        }
        cout << endl;
        for(int i = 0; i <= 3; i++){
            cout << -x[i] * pow(beta, e) << " ";
        }
        cout << endl;
    }

    cout << "欠规格化浮点数:\n";
    double x0[3];
    x0[0] = pow(beta, -2);
    x0[1] = pow(beta, -1);
    x0[2] = pow(beta, -1) + pow(beta, -2);
    for(int i = 0; i <= 2; i++){
        cout << x0[i] * pow(beta, L) << " ";
    }
    cout << endl;
    for(int i = 0; i <= 2; i++){
        cout << -x0[i] * pow(beta, L) << " ";
    }
    cout << endl;

    return 0;
}